﻿using ProjectManager.Interface;
using ProjectManager.Logic.Content;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectManager.Controller
{
    internal partial class LogicController : ILogic
    {
        // 回调方法
        void CallBackMethod(object? obj)
        {
            if (currentProject == null || currentIdentity == null) return;
            // 第一步拉取当前项目的所有分支到对应的地址
            gitController.Pull(CurrentProject.TaskPath, "Task");
            gitController.Pull(CurrentProject.MemberPath, "Member");
            foreach (var task in sqlController.GetTasks(CurrentProject))
            {
                if (!Directory.Exists(task.Path))
                {
                    Directory.CreateDirectory(task.Path);
                    gitController.Clone(CurrentProject.Url, task.Path, task.BranchName);
                }
                else
                    gitController.Pull(task.Path, task.BranchName);
            }
        }
    }
}
